using System.IO;
using SolutionFactory.Services;

namespace SolutionFactory_console
{
	public class DeleteDirectoriesDirectoryVisitor : IDirectoryVisitor
	{
		private readonly string _solutiondir;
		private readonly string[] _dirs;

		public DeleteDirectoriesDirectoryVisitor(string solutiondir,params string[] dirs)
		{
			_solutiondir = solutiondir;
			_dirs = dirs;
		}

		public void Visit(DirectoryInfo info)
		{
			
			if(info.FullName.ToLower().Contains(_solutiondir.ToLower()) )
				foreach (var dir in _dirs)
				{
					if(info.Name.ToLower().EndsWith(dir.ToLower())&&info.Exists)
					{
						info.Delete(true);
					}
				}
		}
	}
}